<?php
use yii\helpers\Url;
use yii\Web\View;
use app\assets\NewUserAsset;
NewUserAsset::register($this);
$this->title = $this->context->pageTitle.Yii::$app->params['titleSuffix'];
$this->params['breadcrumbs'] = [
  [
    'label' => \Yii::t('pack', 'Pack Management'),
    'url' => ['manage']
  ],
  \Yii::t('pack', 'New Pack')
];
$jsMsgs = $this->context->loadJsMsgs([
  'packList',
]);
$this->registerJs("VAM.setVar('LANGUAGE_JS', '".$jsMsgs."');", View::POS_HEAD);
?>
<div class="page-header">
  <h1>
    <?=\Yii::t('pack', 'Pack Management')?>
    <small><?=\Yii::t('pack', 'New')?></small>
  </h1>
</div>
<div class="panel panel-default">
  <div class="panel-heading">
    <i class="fa fa-plus-circle"></i>
    <?=\Yii::t('pack', 'New Pack')?>
    <ul class="list-unstyled pull-right">
      <li>
        <a href="#">
          <i class="fa fa-chevron-up"></i>
        </a>
      </li>
    </ul>
  </div>
  <div class="panel-body">
    <div class="row">
      <div class="col-sm-8 col-sm-offset-2">
        <form class="form-horizontal" id="data-frm" method="POST" action="<?php echo Url::to(['pack/save-pack']);?>">
          <input class="hidden" type="text" name="id" value="">
          <fieldset>
            <div class="form-group">
              <label class="col-sm-2 control-label pl0" for="pack_name" >
                <em>*</em>
                <?=\Yii::t('pack', 'Name')?>：
              </label>
              <div class="col-sm-10">
                <input class="form-control" id="pack_name" type="text" name="name" value="" placeholder="<?=\Yii::t('pack', 'Name')?>">
                <div class="help-block text-error" id="pack_name_err"></div>
              </div>
            </div>
          </fieldset>
          <fieldset>
            <div class="form-group">
              <label class="col-sm-2 control-label" for="pack_type">
                <em>*</em>
                <?=\Yii::t('pack', 'Pack Type')?>：
              </label>
              <div class="col-sm-10">
                <label class="radio-inline">
                  <input class='pack-type' type="radio" name="type" value="1" checked> <?=\Yii::t('pack', 'App')?>
                </label>
                <label class="radio-inline">
                  <input class='pack-type' type="radio" name="type" value="2"> <?=\Yii::t('pack', 'WAP')?>
                </label>
                <div class="help-block"></div>
              </div>
            </div>
            <div class="form-group">
              <label class="col-sm-2 control-label pl0" for="app_selected_list">
                <em>*</em>
                <?=\Yii::t('pack', 'APP List')?>：
              </label>				
              <div class="col-sm-10">
                <select class="form-control" id="app_selected_list" name="app_ids[]" placeholder="<?=\Yii::t('pack', 'Please input keywords')?>..." multiple>
                  <?php 
                    // $out = '';
                    // $isSelected = '';
                    // foreach($advertisers as $id => $advertiser) {
                    // 	$id = $advertiser['id'];
                    // 	$title = $advertiser['name'];						
                    // 	$isSelected = '';
                    // 	//if (in_array($id, $conditions[$condition])) {
                    // 		//$isSelected = 'selected';
                    // 	//}
                    // 	$out .= "<option value='$id' $isSelected>$title</option>";
                    // }
                    // echo $out;
                  ?>
                </select>
                <div class="help-block text-error" id="app_selected_list_err"></div>
              </div>
            </div>
            <div class="form-group">
              <label class="col-sm-2 control-label pl0">
                <?=\Yii::t('pack', 'Suggested Price')?>（CPC/￥）：
              </label>
              <label class="control-label col-md-1 pr0">
                <em>*</em>
                <?=\Yii::t('pack', 'Floor Price')?>：
              </label>
              <div class="col-md-4 pl0">
                <input class="form-control" type="text" id="floor_price" value="" name="floor_price" autocomplete="off">
                <div class="help-block text-error" id="floor_price_err"></div>
              </div>
              <label class="control-label col-md-1 pr0">
                <em>*</em>
                <?=\Yii::t('pack', 'Ceiling Price')?>：
              </label>
              <div class="col-md-4 pl0">
                <input class="form-control" type="text" id="ceiling_price" value="" name="ceiling_price" autocomplete="off">
                <div class="help-block text-error" id="ceiling_price_err"></div>
              </div>
            </div>
          </fieldset>
          <fieldset>
            <div class="form-group">
              <label class="col-sm-2 control-label" for="pack_type">
                <?=\Yii::t('pack', 'Size List')?>：
              </label>
              <div class="col-sm-10">
                <p class="form-control-static" id="app_size_list" name="app_size_list">
                  <span class="list-item">1024*768</span><span class="list-item">, 1242*2208</span><span class="list-item">, 1920*1080</span><span class="list-item">, 200*200</span><span class="list-item">, 210*140</span><span class="list-item">, 300*50</span><span class="list-item">, 320*48</span><span class="list-item">, 320*480</span><span class="list-item">, 320*50</span><span class="list-item">, 358*228</span><span class="list-item vam-hidden">, 480*320</span><span class="list-item">, 600*130</span><span class="list-item">, 640*100</span><span class="list-item">, 660*660</span><span class="list-item">, 720*1035</span><span class="list-item">, 720*124</span><span class="list-item">, 728*90</span><span class="list-item">, 750*1040</span><span class="list-item">, 768*1024</span><span class="list-item">, 984*328</span>
                </p>
              </div>
            </div>
            <div class="form-group" id="material_protocal">
              <label class="col-sm-2 control-label" for="app_format_list">
              <?=\Yii::t('pack', 'Format')?>：
              </label>
              <div class="col-sm-7">
                <p class="form-control-static" id="app_format_list" name="app_format_list">
                  <span class="list-item">JPG</span>
                  <span class="list-item">, PNG</span>
                </p>
              </div>
            </div>
          </fieldset>
          <fieldset>
            <div class="form-group">
              <div class="col-sm-offset-2 col-sm-10">
                <div class="btn-form-group pull-right">
                  <button type="submit" class="btn btn-primary" data-loading-text="<i class='fa fa-spinner fa-spin'></i> <?=\Yii::t('common', 'Saving')?>..."><?=\Yii::t('common', 'Save')?></button>
                  <a href="<?php echo Url::to(['pack/manage']); ?>" class="btn btn-default"><?=\Yii::t('common', 'Back')?></a>
                </div>
              </div>
            </div>
          </fieldset>
        </form>
      </div>
    </div>
  </div>
</div>
<?php
  //$appListUrl = Yii::getAlias('@web') . '/response/pack/appToPackList.php';
  $appListUrl = Yii::getAlias('@web') . 'get-unbind-app';
  //$appSizeAndFormatList = Yii::getAlias('@web') . '/response/pack/appSizeAndFormat.php';
  $appSizeAndFormatList = Yii::getAlias('@web') . 'get-size-list-on-apps';
  $this->registerJs("VAM.setVar('APP_TO_PACK_LIST','$appListUrl');", View::POS_END);
  $this->registerJs("VAM.setVar('APP_SIZE_FORMAT_LIST','$appSizeAndFormatList');", View::POS_END);
?>
<script type="text/javascript" >
  requirejs(["<?= Yii::getAlias('@web/').Yii::$app->params['envDir'];?>/js/site.js"], function(common) {
    requirejs(["<?= Yii::getAlias('@web/').Yii::$app->params['envDir'];?>/js/pack/newPack.js"]);
  });
</script>
